home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_08_07
/
8n07124a
< prev
next >
Wrap
Text File
|
1990-06-17
|
2KB
|
69 lines
1: /*
2: * MDB.H (Generalized Static/Dynamic
3: * Array Version)
4: * Program: Mini-Database
5: * Written by: Leor Zolman
6: * Module: Program Header File
7: */
8:
9: #define TRUE 1
10: #define FALSE 0
11:
12: #define DYN_ARRAY TRUE
13:
14: /*
15: * Prototypes:
16: */
17:
18: int do_menu(struct menu_item *mnu, char *title);
19: void write_db(char *filename);
20: int read_db(char *filename);
21: void edit_db();
22: void fix_db();
23: void backup_db();
24: void error(char *msg);
25: struct record *alloc_rec(void);
26: void free_up();
27:
28: /*
29: * Data Definitions:
30: */
31:
32: struct record { /* Database record definition */
33: char active; /* TRUE if Active, else FALSE */
34: char last[25], first[15];/* Name */
35: long id; /* ID Number */
36: int age; /* Age */
37: char gender; /* M or F */
38: float salary; /* Annual Salary */
39: };
40:
41: #define MAX_RECS 1000 /* Maximum number of records */
42:
43:
44: #ifdef MAIN_MODULE /* Make sure data is only */
45: #define EXTERN /* DEFINED in the main module, */
46: #else /* and declared as EXTERNAL in */
47: #define EXTERN extern /* the other modules. */
48: #endif
49:
50:
51: #if DYN_ARRAY /* Dynamics array allocation: */
52: #define MAX_TO_ADD 100 /* Limit on # of new records */
53: EXTERN struct record *(*recs)[]; /* ptr to array */
54: #define RECS (*recs) /* of ptrs to struct record */
55:
56: #else /* Static array allocation: */
57: EXTERN struct record *recs[MAX_RECS]; /* Array of ptr */
58: #define RECS recs /* to struct of type record */
59: #endif
60:
61: EXTERN int n_recs; /* # of records in current db */
62: EXTERN int max_recs; /* Max # of recs allowed */
63:
64: struct menu_item { /* Menu definition record */
65: int action_code; /* Menu item code */
66: char *descrip; /* Menu item text */
67: };
68: